package web1.orm.mybatis1;

import java.io.InputStream;

import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.*;
public class mybatisFactory {
	private static SqlSessionFactory sqlSessionFactory;
	public static SqlSessionFactory getFactory() {
		if(sqlSessionFactory==null) {
			InputStream inputStream=null;
			try {
				inputStream=Resources.getResourceAsStream("spring.xml");
				sqlSessionFactory=new SqlSessionFactoryBuilder().build(inputStream);
			}catch (Exception e) {
				// TODO: handle exception
				e.printStackTrace();
			}
		}
		return sqlSessionFactory;
		
	}
	public static SqlSession getSqlSession() {
		return getFactory().openSession();
		
	}
	public static SqlSession getSqlSession(boolean isAutoCommit) {
		return getFactory().openSession(isAutoCommit);
		
	}

}
